<%@page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!-- public quote -->
<%@include file="/jsp/comm_css_include.jsp"%>
<link href="${basePath }/css/timeline.css?v=2342" rel="stylesheet">
<!doctype html>
<html>
<head>
<style type="text/css">
li {
	list-style: none;
}

.faile-infor {
	width: 200px;
	float: left;
	font-size: 14px;
	color:#FC1515;
	padding: 14px 0;
}
</style>
</head>
<body class="gray-bg">
	<input type="hidden" id="receiverIds" />
	<input type="hidden" id="channelType" value="${ywBusinessDetail.channelType}" />
	<div class="container creditbody">
		<div class="iboxtitle">
			<span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;财务相关>垫提车款</span>
		</div>
		<div class="buttonfixed">
			<c:if test="${ywBusinessDetail.channelType == 50 }" >
				<button type="button" class="btn dpbtn_red" onclick="noticePeopel();">通知人</button>
			</c:if>	
			<button type="button" class="btn dpbtn_green" id="print" onclick="print();">打印</button>
			<button type="button" class="btn dpbtn_blue" id="saveRemitCar">保存</button>
			<button type="button" class="btn dpbtn_blue" id="submitRemitCar">提交</button>
		</div>
		<form class="form-horizontal business-form" id="commentForm">
			<input id="busiId" name="busiId" type="hidden"
				value="${ywBusinessDetail.id }" /> <input id="queryCreditApplyId"
				name="queryCreditApplyId" type="hidden"
				value="${ywBusinessDetail.queryCreditApplyId }" /> <input
				id="creditQueryId" name="creditQueryId" type="hidden"
				value="${ywBusinessDetail.creditQueryId }" /> <input id="dealerId"
				name="dealerId" type="hidden" value="${ywBusinessDetail.dealerId }" />
			<input id="customerId" name="customerId" type="hidden"
				value="${ywBusinessDetail.customerId }" /> <input id="fundApplyId"
				name="fundApplyId" type="hidden" value="${ywFundApply.id }" />
			<div class="business-history">
				<ul>
					<li>【历史打款】</li>
					<li>${history }</li>
				</ul>
			</div>
			<div class="tche-padding">
				<table cellpadding="0" cellspacing="0" border="0"
					class="infor-table">
					<tr>
						<td align="right"><label class="control-label fontweightBlod">姓名：</label>
						</td>
						<td>
							<div class="control-div fontweightBlod">${ywBusinessDetail.customerName }</div>
						</td>
						<td align="right"><label class="control-label np">身份证号：</label>
						</td>
						<td>
							<div class="control-div np">${ywBusinessDetail.customerNo }</div>
						</td>
					</tr>
					<tr>
						<td align="right"><label class="control-label np">业务编号：</label>
						</td>
						<td>
							<div class="control-div np">${ywBusinessDetail.busiCode }</div>
						</td>

						<td align="right"><label class="control-label np">订单类型：</label>
						</td>
						<td>
							<div class="control-div np">${ywBusinessDetail.channelTypeDisplay }</div>
						</td>
					</tr>

					<tr>
						<td align="right"><label class="control-label np">业务部门：</label>
						</td>
						<td>
							<div class="control-div np">${ywBusinessDetail.orgName }</div>
						</td>

						<td align="right"><label class="control-label np">信贷专员：</label>
						</td>
						<td>
							<div class="control-div np">${ywBusinessDetail.salesmanName }</div>
						</td>
					</tr>
					<tr>
						<td align="right"><label class="control-label np">经销商：</label>
						</td>
						<td>
							<div class="control-div np">${ywBusinessDetail.dealerName }</div>
						</td>
						<td align="right"><label class="control-label np">合作等级：</label>
						</td>
						<td>
							<div class="control-div np">${ywBusinessDetail.dealerLevelDisplay }</div>
						</td>
					</tr>
				</table>
			</div>
			<c:if test="${prepare_account }">
				<%@include file="/jsp/comm_count_infor.jsp"%>
			</c:if>
			<div class="business-manwife">业务进程</div>
			<div class="business-padding" id="">
				<table class="yw-course">
					<thead>
						<tr>
							<th class="splztab bg-grey">按揭日报表</th>
							<th class="splztab bg-grey">申请垫资
								</li>
							<th class="splztab bg-grey">财务审核1</th>
							<th class="splztab bg-grey">财务审核2</th>
							<th class="splztab bg-green">财务垫款</th>
							<th class="splztab">垫款调整A</th>
							<th class="splztab">申请垫款调整Ｂ</th>
							<th class="splztab">垫款调整Ｂ审核</th>
							<th class="splztab">垫款调整Ｂ</th>
							<th class="splztab">财务退款</th>
						</tr>
					</thead>
				</table>
			</div>
			<div class="business-manwife">订单信息</div>
			<div class="business-padding">
				<table cellpadding="0" cellspacing="0" border="0"
					class="infor-table">
					<tr>
						<td align="right"><label class="control-label fontweightBlod">所属分公司：</label>
						</td>
						<td>
							<div class="control-div fontweightBlod" id="">${ywBusinessDetail.orgName }</div>
						</td>
						<td align="right"><label class="control-label np">所属部门：</label>
						</td>
						<td>
							<div class="control-div np" id="">${ywBusinessDetail.proviceOrgName }</div>
						</td>
					</tr>
					<tr>
						<td align="right"><label class="control-label np">业务员：</label>
						</td>
						<td>
							<div class="control-div np" id="">${ywBusinessDetail.salesmanName }</div>
						</td>
					</tr>
					<tr>
						<td align="right"><label class="control-label np">贷款模式：</label>
						</td>
						<td>
							<div class="control-div np" id="">${ywBusinessLoan.loanTypeDisplay }</div>
						</td>
						<td align="right"><label class="control-label np">贷款银行：</label>
						</td>
						<td>
							<div class="control-div np warn-red" id="">${ywBusinessLoan.loanBankDisplay }</div>
						</td>
					</tr>
					<tr>
						<td align="right"><label class="control-label fontweightBlod">贷款本金：</label>
						</td>
						<td>
							<div class="control-div fontweightBlod" id="">
								<fmt:formatNumber type="number"
									value="${empty ywBusinessLoan.loanAmount ? 0 :  ywBusinessLoan.loanAmount}"
									pattern="0.00" maxFractionDigits="2" />
							</div>
						</td>
						<td align="right"><label class="control-label fontweightBlod">签约贷款额：</label>
						</td>
						<td>
							<div class="control-div fontweightBlod" id="">
								<fmt:formatNumber type="number"
									value="${empty ywBusinessLoan.signLoanAmount ? 0 :  ywBusinessLoan.signLoanAmount}"
									pattern="0.00" maxFractionDigits="2" />
							</div>
						</td>
					</tr>
					<tr>
						<td align="right"><label class="control-label np">贷款期限：</label>
						</td>
						<td>
							<div class="control-div np" id="">${ywBusinessLoan.loanMonthDisplay }</div>
						</td>
						<td align="right"><label class="control-label np">公司费率(%)：</label>
						</td>
						<td>
							<div class="control-div np" id="">
								<fmt:formatNumber type="number"
									value="${empty ywBusinessLoan.companyRate ? 0 :  ywBusinessLoan.companyRate * 100}"
									pattern="0.0000" maxFractionDigits="4" />
							</div>
						</td>
					</tr>
					<tr>
						<td align="right"><label class="control-label np">结算方式：</label>
						</td>
						<td>
							<div class="control-div np" id="">${ywFees.typeBalanceDisplay }</div>
						</td>
					</tr>
					<tr>
						<td align="right"><label class="control-label fontweightBlod">主借人姓名：</label>
						</td>
						<td>
							<div class="control-div fontweightBlod" id="">${ywBusinessBuyer.name }</div>
						</td>
						<td align="right"><label class="control-label np">手机号码1：</label>
						</td>
						<td>
							<div class="control-div np" id="">${ywBusinessBuyer.tel1 }</div>
						</td>
					</tr>
					<tr>
						<td align="right"><label class="control-label np">身份证号：</label>
						</td>
						<td>
							<div class="control-div np" id="">${ywBusinessBuyer.idno }</div>
						</td>
						<td align="right"><label class="control-label np">身份证归属地：</label>
						</td>
						<td>
							<div class="control-div np" id="">${ywBusinessBuyer.area }</div>
						</td>
					</tr>
					<tr>
						<td align="right"><label class="control-label np">车辆性质：</label>
						</td>
						<td>
							<div class="control-div np" id="">${ywBusinessCar.carTypeDisplay }</div>
						</td>
						<td align="right"><label class="control-label np">原产地：</label>
						</td>
						<td>
							<div class="control-div np" id="">${ywBusinessCar.carPlaceDisplay }</div>
						</td>
					</tr>
					<tr>
						<td align="right"><label class="control-label np">品牌：</label>
						</td>
						<td>
							<div class="control-div np" id="">${ywBusinessCar.nameCarBrand }</div>
						</td>
						<td align="right"><label class="control-label np">车系：</label>
						</td>
						<td>
							<div class="control-div np" id="">${ywBusinessCar.nameCarSeries }</div>
						</td>
					</tr>
					<tr>
						<td align="right"><label class="control-label np">车型：</label>
						</td>
						<td colspan="3">
							<div class="control-div np" id="">${ywBusinessCar.nameCarModel }</div>
						</td>
					</tr>
					<tr>
						<td align="right"><label class="control-label np">经销商：</label>
						</td>
						<td colspan="3">
							<div class="control-div np" id="">${ywBusinessDetail.dealerName }</div>
						</td>
					</tr>
					<tr>	
						<td align="right"><label class="control-label np">合作等级：</label>
						</td>
						<td>
							<div class="control-div np" id="">${ywBusinessDetail.dealerLevelDisplay }</div>
						</td>
						<td align="right"><label class="control-label np">车价/二手车估价：</label>
						</td>
						<td>
							<div class="control-div np" id="">
								<fmt:formatNumber type="number"
									value='${"02".equals(ywBusinessCar.carType) ? (empty ywBusinessLoan.carEstimatePrice ? 0 :  ywBusinessLoan.carEstimatePrice) : (empty ywBusinessCar.price ? 0 :  ywBusinessCar.price)}'
									pattern="0.00" maxFractionDigits="2" />
							</div>
						</td>
					</tr>
				</table>
			</div>
			<div class="business-manwife">申请垫资信息</div>
			<div class="tche-padding">
				<table cellpadding="0" cellspacing="0" border="0"
					class="infor-table">
					<tr>
						<td align="right"><label class="control-label np">提车时间：</label>
						</td>
						<td>
							<div class="control-div np" id="dateFist">
								<fmt:formatDate value='${ywFundApply.dateFist}'
									pattern='yyyy-MM-dd HH:mm' />
							</div>
						</td>
					</tr>
					<tr>
						<td align="right"><label class="control-label np">备注：</label>
						</td>
						<td>
							<div class="control-div np" id="remarks_chli">${ywFundApply.remarks }</div>
						</td>
					</tr>
				</table>
			</div>
			<a name="feeDetail" style="cursor: text;"><div class="business-manwife">费用明细</div></a>
			<div class="tche-padding">
				<table cellpadding="0" cellspacing="0" border="0" class="thead-table padding-wangge">
					<thead class="thead-a">
						<tr>
							<th class="warn-red-bold">贷款本金</th>
							<th class="warn-red-bold">签约贷款额</th>
							<c:if test="${!empty fundItems_ }">
								<c:forEach items="${fundItems_ }" var="fundItem_" varStatus="status">
									<th class="warn-red-bold">${fundItem_.name }</th>
								</c:forEach>
							</c:if>
						</tr>
					</thead>
					<tbody class="tbody-a">
						<tr>
							<td class="zxyjred"><fmt:formatNumber type="number" value="${empty ywBusinessLoan.loanAmount ? 0 : ywBusinessLoan.loanAmount}" pattern="0.00" maxFractionDigits="2" /></td>
							<td class="zxyjred"><fmt:formatNumber type="number" value="${empty ywBusinessLoan.signLoanAmount ? 0 :  ywBusinessLoan.signLoanAmount}" pattern="0.00" maxFractionDigits="2" /></td>
							<c:if test="${!empty fundItems_ }">
								<c:forEach items="${fundItems_ }" var="fundItem_" varStatus="status">
									<td class="zxyjred"><fmt:formatNumber type="number" value="${empty fundItem_.feeCount ? 0 : fundItem_.feeCount}" pattern="0.00" maxFractionDigits="2" /></td>
								</c:forEach>
							</c:if>
						</tr>
					</tbody>
				</table>
				<c:choose>
					<c:when test="${!empty fundItems }">
						<ul class="thead-tableul">
							<c:forEach items="${fundItems }" var="cwFundItem"
								varStatus="status">
								<c:if test="${status.index % 7 == 0 }">
									<li>
										<table cellpadding="0" cellspacing="0" border="0"
											class="thead-table">
											<thead class="thead-a">
												<tr>
													<th></th>
													<th>应收</th>
													<th>实收</th>
												</tr>
											</thead>
											<tbody class="tbody-a">
												</c:if>
												<tr>
													<td
														<c:if test="${cwFundItem.key == '03'}"> style="color:#FC1515;"</c:if>
														<c:if test="${cwFundItem.key == '25'}"> style="color:#FC1515;"</c:if>>${cwFundItem.name }
													</td>
													<td <c:if test="${cwFundItem.key == '03'}"> style="color:#FC1515;"</c:if>
														<c:if test="${cwFundItem.key == '25'}"> style="color:#FC1515;"</c:if> id="fee_td_${cwFundItem.key }">
														<fmt:formatNumber type="number" value="${cwFundItem.feeCount }" pattern="0.00" maxFractionDigits="2" /></td>
													<td <c:if test="${cwFundItem.key == '03'}"> style="color:#FC1515;"</c:if>
														<c:if test="${cwFundItem.key == '25'}"> style="color:#FC1515;"</c:if> id="remit_td_${cwFundItem.key }">
														<fmt:formatNumber type="number" value="${cwFundItem.remitCount }" pattern="0.00" maxFractionDigits="2" /></td>
												</tr>
												<c:if test="${status.index % 7 == 6  || status.last}">
											</tbody>
										</table>
									</li>
								</c:if>
							</c:forEach>
						</ul>
					</c:when>
					<c:otherwise>
        				没有收费项目
        			</c:otherwise>
				</c:choose>
				<ul class="thead-tableul">
					<li>
						<table cellpadding="0" cellspacing="0" border="0"
							class="thead-table">
							<thead class="thead-a">
								<tr>
									<th></th>
									<th>应收</th>
									<th>实收</th>
								</tr>
							</thead>
							<tbody class="tbody-a">
								<tr>
									<td class="npb style-red">应收合计</td>
									<td id="totalFee"><fmt:formatNumber type="number"
											value="${fundTotal.feeCount }" pattern="0.00"
											maxFractionDigits="2" /></td>
									<td id="totalRemit"><fmt:formatNumber type="number"
											value="${fundTotal.remitCount }" pattern="0.00"
											maxFractionDigits="2" /></td>
								</tr>
							</tbody>
						</table>
					</li>
				</ul>
				<ul class="thead-tableul">
        		<li>
        		<table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table">
        		 <tr>
					<td align="right">
						<label class="control-label np">垫款返利：</label>
					</td>
					<td> 
						<input id="remitCarId" name="remitCarId" type="hidden" value="${cwRemitCar.id }" />
						<input class="form-control" type="text" id="feePromotionReal" name="feePromotionReal" required="required" placeholder="垫款返利(必填)" value='<fmt:formatNumber type="number" value="${empty cwRemitCar.feePromotionReal ? 0 : cwRemitCar.feePromotionReal}" pattern="0.00" maxFractionDigits="2"/>' onkeyup="countAmountPaymentTotalReal();" onafterpaste="countAmountPaymentTotalReal();"/>
					</td>	
				      <td class="npb style-red" style="display: none;">应付合计</td>
				      <td style="display: none;"><fmt:formatNumber type="number" value="${empty ywFees.amountPaymentTotal ? 0 : ywFees.amountPaymentTotal }" pattern="0.00" maxFractionDigits="2"/></td>
				      <td style="display: none;"><input class="tbody-control" type="text" id="amountPaymentTotalReal" name="amountPaymentTotalReal"  value="${empty cwRemitCar.amountPaymentTotalReal ? 0 : cwRemitCar.amountPaymentTotalReal}" readonly="readonly" /></td>
				</tr>
				</table>
        		</li>
        	</ul> 
			</div>

			<div class="business-manwife">返利信息</div>
			<div class="business-padding">
				<table cellpadding="0" cellspacing="0" border="0"
					class="infor-table">
					<tr>
						<td align="right"><label class="control-label np">经销商返利：</label>
						</td>
						<td>
							<div class="control-div np" id="">
								<fmt:formatNumber type="number"
									value="${empty ywFees.rebateDealer ? 0 : ywFees.rebateDealer}"
									pattern="0.00" maxFractionDigits="2" />
							</div>
						</td>
						<td align="right"><label class="control-label np">分公司展业费：</label>
						</td>
						<td>
							<div class="control-div np" id="">
								<fmt:formatNumber type="number"
									value="${empty ywFees.rebateProvince ? 0 : ywFees.rebateProvince}"
									pattern="0.00" maxFractionDigits="2" />
							</div>
						</td>
					</tr>
					<tr>
						<td align="right"><label class="control-label np">区域&业务员展业费：</label>
						</td>
						<td>
							<div class="control-div np" id="">
								<fmt:formatNumber type="number"
									value="${empty ywFees.rebateArea ? 0 :  ywFees.rebateArea}"
									pattern="0.00" maxFractionDigits="2" />
							</div>
						</td>
						<td align="right"><label class="control-label np">返利方式：</label>
						</td>
						<td>
							<div class="control-div np" id="">${empty ywFees.rebateTypeDisplay ? '-' : ywFees.rebateTypeDisplay}
						</td>
					</tr>
				</table>
			</div>

			<div class="business-manwife clear-both">资金打款<c:if test="${isSpecialOrder}" >（<span style="color:#FC1515;">该订单被风控标注为特殊订单，银行先放款财务再打款！</span>）</c:if></div>
			<div class="tche-padding">
				<table cellpadding="0" cellspacing="0" border="0"
					class="buyinfor-table">
					<input id="remitCarId" name="remitCarId" type="hidden"
						value="${cwRemitCar.id }" />
					<tr>
						<td align="right"><label class="control-label np" >资金渠道(过桥贷)：</label>
						</td>
						<td>
						<c:choose>
							<c:when test="${hasRefunded || empty ywBusinessDetail.busiType || ywBusinessDetail.busiType == 'zy'}">
								<mytag:selectTag id="fundChannel" name="fundChannel"
								map="${fundChannel }" selected="zy" 
								others="class='select-control' required='required' disabled='disabled'"
								firstoption="true" />
							</c:when>
							<c:otherwise>
								<mytag:selectTag id="fundChannel" name="fundChannel"
								map="${fundChannel }" selected="${cwRemitCar.fundChannel }"
								others="class='select-control' required='required'"
								firstoption="true" />
							</c:otherwise>
						</c:choose>
						</td>
						<c:choose>
							<c:when test="${hasRefunded }">
								<td colspan="2" valign="middle">
									<div class="control-div np">&nbsp;&nbsp;&nbsp;历史退款时间：<fmt:formatDate value='${refundTimeArrive }' pattern='yyyy-MM-dd HH:mm' /></div>
								</td>
							</c:when>
							<c:otherwise>
								<td class="fundChannelChange" colspan="2" valign="middle">
									<div class="control-div np" id="">&nbsp;&nbsp;&nbsp;${empty ywBusinessDetail.thirdBusiStatusDisplay ? '到账情况：未知' : '到账情况：'.concat(ywBusinessDetail.thirdBusiStatusDisplay)}（ 最多垫付20万）</div>
								</td>
							</c:otherwise>
						</c:choose>
					</tr>
					<c:if test="${tjgsyh == ywBusinessDetail.loanBank}">
						<tr>
							<td align="right"><label class="control-label np">天津中转账号：</label>
							</td>
							<td colspan="3">
							<mytag:selectTag id="ccol1" name="ccol1" map="${tjTransferAccno }" selected="${cwRemitCar.ccol1 }"
									others="class='select-control' required='required'"
									firstoption="true" /></td>
						</tr>
					</c:if>
					<tr>
						<td align="right"><label class="control-label np">收款帐户：</label>
						</td>
						<td colspan="3"><input id="nameBankReceiver"
							name="nameBankReceiver" type="hidden"
							value="${cwRemitCar.nameBankReceiver }" /> <input
							id="accountNameReceiver" name="accountNameReceiver" type="hidden"
							value="${cwRemitCar.accountNameReceiver }" /> <input
							id="accounnNoReceiver" name="accounnNoReceiver" type="hidden"
							value="${cwRemitCar.accounnNoReceiver }" /> <mytag:selectTag
								id="accountReceiver" name="accountReceiver"
								map="${accountReceivers }"
								others="class='select-control' required='required'"
								firstoption="true" /></td>
					</tr>
					<tr>
						<td align="right"><label class="control-label np">打款银行：</label>
						</td>
						<td colspan="3"><input id="typeBalance_remit" name="typeBalance_remit"
							type="hidden" value="${ywFees.typeBalance }" /> <mytag:selectTag
								id="bankRemit" name="bankRemit" map="${loanBank }"
								selected="${cwRemitCar.bankRemit }"
								others="class='select-control' required='required'" firstoption="true" /></td>
					</tr>
					<tr>
						<td align="right"><label class="control-label np">打款金额：</label>
						</td>
						<td class="td-width"><input id="amountRemit" name="amountRemit"
							required="required" placeholder="打款金额(必填)" class="form-control"
							type="number"
							value='<fmt:formatNumber type="number" value="${cwRemitCar.amountRemit }" pattern="0.00" maxFractionDigits="2"/>' />
						</td>
						<td align="right"><label class="control-label np">财务档案编号：</label>
						</td>
						<td class="td-width"><input id="financialRecordsNumber"
							name="financialRecordsNumber" placeholder="档案编号"
							class="form-control"
							value="${cwRemitCar.financialRecordsNumber }" /></td>
					</tr>
					
					<tr>
						<td align="right"><label class="control-label np">打款时间：</label>
						</td>
						<td class="td-width"><input id="timeRemit" name="timeRemit" required="required" placeholder="打款时间(必填)"
							class="laydate-icon form-control"
							value="<fmt:formatDate value='${cwRemitCar.timeRemit }' pattern='yyyy-MM-dd hh:mm:ss' />" />
						</td>
						<td align="right"><label class="control-label np">到账时间：</label>
						</td>
						<td class="td-width"><input id="timeArrive" name="timeArrive"
							placeholder="到账时间" class="laydate-icon form-control"
							value="<fmt:formatDate value='${cwRemitCar.timeArrive }' pattern='yyyy-MM-dd hh:mm' />" />
						</td>
					</tr>
					<tr>
						<td align="right"><label class="control-label np">财务审核人：</label>
						</td>
						<td class="td-width"><mytag:selectTag id="nameAuditor" name="nameAuditor"
								map="${remitFinanceAuditor }" selected="${cwRemitCar.nameAuditor }"
								others="class='select-control' required='required'" /></td>
						<td align="right"><label class="control-label np">财务审核时间：</label>
						</td>
						<td class="td-width"><input id="timeAudit" name="timeAudit"
							placeholder="财务审核时间" class="laydate-icon form-control"
							value="<fmt:formatDate value='${cwRemitCar.timeAudit }' pattern='yyyy-MM-dd'/>" />
						</td>
					</tr>
					<tr>
						<td align="right" valign="top"><label class="control-label">备注：</label>
						</td>
						<td colspan="4"><textarea id="remarks" name="remarks"
								rows="3" cols="" class="form-control">${cwRemitCar.remarks }</textarea>
						</td>
					</tr>
				</table>
			</div>
			<!-- 当前经办人 -->
			<%@include file="/jsp/comm_current_person_include.jsp"%>
		</form>
	</div>

	<!-- public quote -->
	<%@include file="/jsp/comm_js_include.jsp"%>
	<!-- summernote -->
	<%@include file="/js/common-dpqc/dpqc-summernote/comm_summernote_include.jsp"%>
	<%@include file="/jsp/notice_people_choice.jsp"%> 
	<!-- layerDate plugin javascript -->
	<script type="text/javascript" src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>
	<!-- custom js -->
	<%@include file="/js/common-dpqc/dpqc-validate/comm_validate_include.jsp"%>
	<script type="text/javascript"></script>
	<!--
    	时间：2017-04-06
    	描述：js
    -->
	<script type="text/javascript">
	    jQuery(function($) {  
	    	getDataS('a2be6ac69de84ba8bc5d3778c000ecf2');
	    	//外部js调用
		    laydate({
		        elem: '#timeRemit', 
		        event: 'focus',
		        istime: true,
		        format: 'YYYY-MM-DD hh:mm:ss',
		        start: laydate.now(0,"YYYY-MM-DD hh:mm:ss"),  //设置开始时间为当前时间  
		    });
		    laydate({
		        elem: '#timeArrive', 
		        event: 'focus',
		        istime: true,
		        format: 'YYYY-MM-DD hh:mm'
		    });
		    laydate({
		        elem: '#timeAudit', 
		        max:laydate.now(),
		        event: 'focus' 
		    });
		    
		    var timeRemit = document.getElementById('timeRemit').value;
		    if(timeRemit == ""){
		    	document.getElementById('timeRemit').value = laydate.now(0,"YYYY-MM-DD hh:mm:ss");
		    }
		    
		    $('#saveRemitCar').click(function(){
		    	save(false);
		    });
		    
		    var notEquallayer;
		    $('#submitRemitCar').click(function(){
			    	var validstatus = $("#commentForm").valid();
			    	if(!validstatus) {
			    		layer.msg("有验证未通过，请检查！", {icon: 5,time:1500});
						return;
			    	}
		    		if(validateFeeAndRemit()) {
		    			confirmSaveAction(true);
		    		} else {
		    			if($("#channelType").val() == 50){
							if($("#receiverIds").val() == ""){
								layer.msg("请选择通知人再提交！", {icon: 5,time:1500});
								return;
							}
						}
		    			notEquallayer = layer.confirm('应收和实收不一致,确认提交吗 ?', {
						  title:'应收实收不一致确认',
						  btn: ['确认提交','不提交']
						}, function(){
							confirmSaveAction(true);
						}, function(){
							layer.closeAll();
						});
		    	   }
		    });
		    
		    $('#fundChannel').change(function(){
		    	fundChannelChange();
		    });
		    
		    $('#accountReceiver').change(function(){
		    	changeAccountReceiver(false);
		    });
		    
		    fundChannelChange();
		    changeAccountReceiver(true);
	    });
	    /**
	     * 渠道修改
	     */
	    function fundChannelChange(){
	    	var fundChannel = $('#fundChannel').val();
	    	if((!fundChannel || (fundChannel && fundChannel == 'zy'))) {
	    		$('.fundChannelChange').hide();
	    	} else {
	    		$('.fundChannelChange').show();
	    	}
	    }
	    
		//确认签署
		var saveLayer;
		function save(commit){
			if(commit){
				saveLayer = layer.confirm('确认垫提车款吗 ?', {
					  title:'垫提车款提交',
					  btn: ['确认','返回修改'] //按钮
					}, function(){
						saveAction(commit);
					}, function(){
						layer.closeAll();
					});
			} else {
				saveAction(commit);
			}
			
		}
		var confirmSaveActionLayer;
		function confirmSaveAction(commit) {
			if(${isSpecialOrder}) {
				confirmSaveActionLayer = layer.confirm('该订单被风控标注为特殊订单,确认提交吗?', {
					  title:'特殊订单确认',
					  btn: ['确认提交','不再提交']
					}, function(){
						save(commit);
					}, function(){
						layer.closeAll();
					});
			}else{
				save(commit);
			}
		}
		function saveAction(commit) {
			var data = {};
			data.commit = commit; //控制字段
			data.id = $('#remitCarId').val();
			data.busiId = $('#busiId').val();
			data.fundChannel = $('#fundChannel').val();
			data.nameBankReceiver = $('#nameBankReceiver').val();
			data.accountNameReceiver = $('#accountNameReceiver').val();
			data.accounnNoReceiver = $('#accounnNoReceiver').val();
			data.typeBalance = $('#typeBalance_remit').val();
			data.fundApplyId = $('#fundApplyId').val();
			data.cusId = $('#customerId').val();
			data.amountRemit = $('#amountRemit').val();
			data.bankRemit = $('#bankRemit').val();
			data.timeRemit = $('#timeRemit').val();
			data.timeArrive = formateToMinutes($('#timeArrive').val(),true);
			data.nameAuditor = $('#nameAuditor').val();
			data.timeAudit = $('#timeAudit').val();
			data.financialRecordsNumber = $('#financialRecordsNumber').val();
			data.ccol1 = $('#ccol1').val(); //天津中转账号
			data.remarks = $('#remarks').val();
			
			data.amountPaymentTotalReal = $('#amountPaymentTotalReal').val();
			if(commit) {
				data.receiverIds = $("#receiverIds").val();
			}
			data.feePromotionReal = $('#feePromotionReal').val();
			$.dpAjax({
 	    		url:'${basePath}/CwRemitCarController/remitCar',
 	    		data:data,
     			success: function(datas){
     				 $('#remitCarId').val(datas.result);
     				 if(commit) {
     					 layer.msg("垫提车款提交成功！", {icon: 6,time:1500});
	     				 setTimeout(function(){
	     					location.href='${basePath}/web/system/cw/remitCar.jsp'; 
	     				 },1500);
     				 } else {
     					 layer.msg("垫提车款保存成功！", {icon: 6,time:1500});
     				 }
                 }
 	    	});
		}
		//计算实付
		function countAmountPaymentTotalReal(){
			var feePromotionReal = $('#feePromotionReal').val();
	    	var feePromotionRealNum = (!feePromotionReal || feePromotionReal == '') ? 0 : parseFloat(feePromotionReal);
			
	    	$('#amountPaymentTotalReal').val(feePromotionRealNum.toFixed(2));
		}
		
		$(function(){
	        $("#commentForm").validate({
	            rules: {
	            	amountRemit:{
	            		allMoney: true,
	            	}
	            },
	            //重写showErrors
	            showErrors: function (errorMap, errorList) {
	                
	                $.each(errorList, function (i, v) {
	                    layer.tips(v.message, v.element, { time: 1500 });
	                    return false;
	                });  
	            },
	            /* 失去焦点时验证 */
	            onfocusout: function(element) { $(element).valid(); },
	            /*  键盘抬起不验证 */
	            onkeyup:false,
	        });
		});
		
		//验证应收和实收
		function validateFeeAndRemit(){
			var feeCount = $('#totalFee').text();
			var remitCount = $('#totalRemit').text();
			if(!feeCount || feeCount == '') {
				feeCount = '0';
			}
			if(!remitCount || remitCount == '') {
				remitCount = '0';
			}
			return parseFloat(feeCount).toFixed(2) == parseFloat(remitCount).toFixed(2);
		}
		
		//验证应收和实收
		function validateFeeAndRemitOld(){
			var validateResult = true;
			var prefix = "fee_td_";
			$('td[id^="fee_td_"]').each(function() {
				var feeId = $(this).attr('id');
				var fundKey = feeId.substring(prefix.length, feeId.length);
				var feeCount = $(this).text().trim();
				var remitCount = $('td[id="remit_td_'+ fundKey+ '"]').text().trim();
				if(!feeCount || feeCount == '') {
					feeCount = '0';
				}
				if(!remitCount || remitCount == '') {
					remitCount = '0';
				}
				if(parseFloat(feeCount).toFixed(2) != parseFloat(remitCount).toFixed(2)) {
					validateResult = false;
					 /*layer.tips('应收实收必须一致','td[id="remit_td_'+ fundKey+ '"]');
					location.href ="#feeDetail"; */
					return false;
				}
			});
			return validateResult;
		}
		//收款账号
		function changeAccountReceiver(init){
			var nameBankReceiver = $('#nameBankReceiver').val();
			var accountNameReceiver = $('#accountNameReceiver').val();
			var accounnNoReceiver = $('#accounnNoReceiver').val();
			if(init && nameBankReceiver && nameBankReceiver != '') { //初始化时
				$('#accountReceiver option').each(function(){
					var id = $(this).attr('value');
					var accountReceiver = $(this).text();
					if(accountReceiver && accountReceiver != '') {
						if(accountReceiver.endWith(nameBankReceiver + '-' + accountNameReceiver + '-' + accounnNoReceiver)) {
							$('#accountReceiver').val(id);
							return false;
						}
					}
				});
			} else { //改变时
				var accountReceiver = $('#accountReceiver option:selected').text();
				if(accountReceiver && accountReceiver != '') {
					if(accountReceiver.indexOf(":") > 0) {
						var accountReceiver_ = accountReceiver.split(':')[1];
						var accountReceivers = accountReceiver_.split("-");
						$('#nameBankReceiver').val(accountReceivers[0]);
						$('#accountNameReceiver').val(accountReceivers[1]);
						$('#accounnNoReceiver').val(accountReceivers[2]);
					}
				}
			}
		}
		
		function print(){
			var busiId = $('#busiId').val();
	    	$.dpAjax({
	    		url:'${basePath}/CwRemitCarController/print',
	    		type:'POST',
	    		data:{busiId:busiId,check:true},
	    		success:function(datas)	{
	    			//成功响应，说明没有报错，可以下载
	    			location.href='${basePath}/CwRemitCarController/print?busiId='+	busiId;
	    			return;
	    		}
	    	});
		}
		
		function noticePeopel(){
			layer.open({
	    	  type: 1,
	    	  title:'选择通知人',
	    	  area: ['410px', '550px'], //宽高
	    	  content: $("#noticeChoice")
	    	})
		}
		
		
		//确定通知人
		function savecachedUsers(){
			$("#receiverIds").val(cachedUsers);
			layer.closeAll();
		}
		
    </script>
</body>
</html>
